package com.edu.exam.entity.assessment.scheme;

import com.edu.exam.enums.assessment.scheme.TemplateApplicationScenario;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

/**
 * 考核方案模板实体类
 * 所属模块：B-04 考核方案管理模块
 * 对应数据库表：assessment_scheme_template
 *
 * <p>考核方案模板是可重用的考核方案模板，用于提高方案创建效率。
 * 支持按类型查询和应用模板功能。模板内容以JSON格式存储，支持灵活的结构定义。</p>
 *
 * @author 系统生成
 * @version 2.0
 * @since 2025-11-09
 */
@Entity
@Data
@EqualsAndHashCode(callSuper = false)
@EntityListeners(AuditingEntityListener.class)
public class AssessmentSchemeTemplate {

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 模板名称
     */
    @Column(name = "name", nullable = false, length = 200)
    private String name;

    /**
     * 模板描述
     */
    @Column(name = "description", columnDefinition = "TEXT")
    private String description;

    /**
     * 模板类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "type", nullable = false, length = 50)
    private TemplateApplicationScenario type;

    /**
     * 模板内容（JSON格式）
     */
    @Column(name = "content", nullable = false, columnDefinition = "TEXT")
    private String content;

    /**
     * 是否启用
     */
    @Column(name = "is_active", nullable = false)
    private Boolean isActive = true;

    /**
     * 模板版本
     */
    @Column(name = "version", length = 20)
    private String version;

    /**
     * 适用课程类型
     */
    @Column(name = "applicable_course_type", length = 100)
    private String applicableCourseType;

    /**
     * 适用学科
     */
    @Column(name = "applicable_subject", length = 100)
    private String applicableSubject;

    /**
     * 适用年级
     */
    @Column(name = "applicable_grade", length = 100)
    private String applicableGrade;

    /**
     * 使用次数
     */
    @Column(name = "usage_count")
    private Integer usageCount = 0;

    /**
     * 最后使用时间
     */
    @Column(name = "last_used_time")
    private LocalDateTime lastUsedTime;

    /**
     * 模板标签
     */
    @Column(name = "tags", length = 500)
    private String tags;

    /**
     * 模板预览
     */
    @Column(name = "preview", columnDefinition = "TEXT")
    private String preview;

    /**
     * 创建人ID
     */
    @Column(name = "creator_id", nullable = false)
    private Long creatorId;

    /**
     * 创建人姓名
     */
    @Column(name = "creator_name", length = 100)
    private String creatorName;

    /**
     * 更新人ID
     */
    @Column(name = "updater_id")
    private Long updaterId;

    /**
     * 更新人姓名
     */
    @Column(name = "updater_name", length = 100)
    private String updaterName;

    /**
     * 创建时间
     */
    @CreatedDate
    @Column(name = "create_time", nullable = false, updatable = false)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @LastModifiedDate
    @Column(name = "update_time", nullable = false)
    private LocalDateTime updateTime;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;

    /**
     * 删除时间
     */
    @Column(name = "deleted_time")
    private LocalDateTime deletedTime;

    /**
     * 删除人ID
     */
    @Column(name = "deleted_by")
    private Long deletedBy;

    }